package clear.samples.android.integration;

import java.util.ArrayList;
import java.util.List;

import clear.samples.android.integration.contactmanager.ContactManager;
import clear.samples.android.integration.dto.ContactPhoneDTO;


import android.app.Application;
import android.database.Cursor;

import winstone.Launcher;

public class RemoteObject {
	public String getHelloWord() {
		return "Hello Word!";
	}

	public List<ContactPhoneDTO> getContactPhones() {
		ArrayList<ContactPhoneDTO> result = new ArrayList<ContactPhoneDTO>();
		Cursor cursor = ContactManager.getPhones();
		if (cursor.moveToFirst()) {
			do {
				ContactPhoneDTO dto = new ContactPhoneDTO();
				dto.setId(cursor.getString(0));
				dto.setDisplayName(cursor.getString(1));
				dto.setPhoneNumber(cursor.getString(2));
				result.add(dto);
			} while (cursor.moveToNext());
		}
		cursor.close();
		return result;
	}
	

	public void recognizeVoice(int requestCode, String prompt) {
		CustomActivity.instance.recognizeVoice(requestCode, prompt);
	}
	
	public void showDialog(int dialogId) {
		CustomActivity.instance.showDialog(dialogId);
	}
	
	public void close() {
		Launcher.instance.shutdown();
		CustomActivity.instance.finish();
		int pid = android.os.Process.myPid();
        android.os.Process.killProcess(pid);
	}
}
